//
//  EventHandler.swift
//  mall-ios
//
//  Created by Meak Tsui on 2018/11/26.
//  Copyright © 2018 Meak Tsui. All rights reserved.
//

import Foundation
import WebKit
import Shared

public protocol MTEventHandler {
    var ns:Ns {get}
    var action:Api {get}    
    func handler(_ msg:MTHybridMsg)
}

public class MTEmptyEventHandler: MTEventHandler {
    public var ns: Ns {
        return self.disabledNs
    }
    
    public var action: Api {
        return self.disabledAction
    }
    
    public func handler(_ msg: MTHybridMsg){
        dPrint(debugLogStr())
        msg.callbackClosure?([:])
    }
    
    func debugLogStr() -> String {
        return "未找到ns:\(self.ns.rawValue),action:\(self.action.rawValue)的handler"
    }
    
    private var disabledNs:Ns
    private var disabledAction:Api
    
    init(ns:Ns,action:Api) {
        self.disabledNs = ns
        self.disabledAction = action
    }
    
}
